<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="app">
      <div v-for="item in list" :key="item.id">
        {{item.name}}

        <input type="text" />
      </div>

      <button @click="fn1">尾部添加</button>
      <button @click="fn2">头部添加</button>
    </div>

    <script src="../lib/vue-3.js"></script>

    <script>
      const app = Vue.createApp({
        data() {
          return {
            list: [
              { id: 1, name: "张三" },
              { id: 2, name: "里斯" },
              { id: 3, name: "王五" },
            ],
          };
        },

        methods: {
          fn1() {
            this.list.push({ id: 4, name: "马六" });
          },

          fn2() {
            this.list.unshift({ id: 5, name: "赵七" });
          },
        },
      });

      app.mount("#app");
    </script>
  </body>
</html>
